package com.lagou.product.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.pojo.ProductVO;
import com.lagou.pojo.Products;
import com.lagou.product.mapper.ProductMapper;
import com.lagou.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;
    //根据id查询商品信息
    @Override
    public Products queryById(Integer productId) {
        return productMapper.selectById (productId);
    }

    @Override
    public PageInfo<Products> queryByPage(ProductVO productVO) {
        //分页查询
        PageHelper.startPage (productVO.getCurrentPage (),productVO.getPageSize ());
        List<Products> list = productMapper.selectByPage (productVO);
        return new PageInfo<> (list);
    }

    @Override
    public int deleteById(Integer id) {
        return productMapper.deleteById (id);
    }

    @Override
    public int updateById(Products products) {
        return productMapper.updateById (products);
    }
}
